Skip to content

Fix gradient-checkpointing option is ignored in SDXL+LoRA training. (#6388)#6402

Merged
sayakpaul merged 5 commits intohuggingface:mainfrom
2510:fix-gradient-checkpointing-ignored-in-sdxl-lora
Jan 1, 2024
Merged

Fix gradient-checkpointing option is ignored in SDXL+LoRA training. (#6388)#6402
sayakpaul merged 5 commits intohuggingface:mainfrom
2510:fix-gradient-checkpointing-ignored-in-sdxl-lora

Conversation

@2510
Copy link
Copy Markdown
Contributor

@2510 2510 commented Dec 30, 2023

What does this PR do?

Fixes a problem in SDXL LoRA training script that ignores gradient checkpointing option.

Fixes #6388

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@2510
Copy link
Copy Markdown
Contributor Author

2510 commented Dec 30, 2023

@sayakpaul Here is a PR for #6388.
I found same problem for SD1-LoRA and fixed in the same way.

Comment on lines +709 to +710
if args.gradient_checkpointing:
unet.enable_gradient_checkpointing()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The text encoder can be trainable in this script too:

This is how it's done:

text_encoder_one.gradient_checkpointing_enable()

Copy link
Copy Markdown
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment. Thank you.

@2510
Copy link
Copy Markdown
Contributor Author

2510 commented Dec 31, 2023

@sayakpaul Thanks for your review. Fixed that in 8d7feb6.

@sayakpaul sayakpaul merged commit 8a366b8 into huggingface:main Jan 1, 2024
@sayakpaul
Copy link
Copy Markdown
Member

Thanks for your contributions.

antoine-scenario pushed a commit to antoine-scenario/diffusers that referenced this pull request Jan 2, 2024
…uggingface#6388) (huggingface#6402)

* Fix gradient-checkpointing option is ignored in SDXL+LoRA training. (huggingface#6388)

* Fix gradient-checkpointing option is ignored in SD+LoRA training.

* Fix gradient checkpoint is not applied to text encoders. (SDXL+LoRA)

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
…uggingface#6388) (huggingface#6402)

* Fix gradient-checkpointing option is ignored in SDXL+LoRA training. (huggingface#6388)

* Fix gradient-checkpointing option is ignored in SD+LoRA training.

* Fix gradient checkpoint is not applied to text encoders. (SDXL+LoRA)

---------

Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gradient-checkpointing ignored in SDXL+LoRA training

3 participants